﻿@{
    ViewBag.Title = "Index";
}
<link href="~/Content/css/framework-theme.css" rel="stylesheet" />
<link href="~/Content/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/select2/select2.min.js"></script>
<script src="/Content/dropzone/dropzone.min.js"></script>

@Html.Partial("Index_js")
<style type="text/css">
    /*
    .img_thum {max-width:100px;}*/
</style>
<style type="text/css">
    #picker {
        display: inline-block;
        line-height: 10px;
        vertical-align: middle;
        margin: 0 12px 0 0;
    }

    .img_thum {
        width: 100px;
        margin-right: 5px;
    }

    .img_red {
        border: 1px solid #ff6a00;
    }

    #thelist {
        overflow-y: hidden;
        overflow-x: scroll;
    }
</style>
<style type="text/css">
    .img_thum {
        width: 100px;
        height: 100px;
    }

    #thelist {
        overflow-y: hidden;
    }

    .a-btn .fa {
        vertical-align: middle;
        font-size: 12px;
    }
</style>
<div style="width:100%;">
    <div class="topPanel">
        <div class="toolbar">
            <a class="a-btn-refresh" onclick="$ace.reload()"></a>
            <button class="a-btn-edit" data-bind="click:edit,disable:!dataTable.selectedModel()">修改</button>
            <button class="a-btn-add" data-bind="click:add">添加</button>
            <button class="a-btn-delete" data-bind="click:del,disable:!dataTable.selectedModel()">删除</button>
            <!-- <button class="a-btn-edit" data-bind="click:openRevisePasswordDialog,disable:!dataTable.selectedModel()">商家程序码</button>-->
        </div>
        <div class="search">
            <table class="form-table" style="width:auto;">
                <tr>
                    <td style="width:100px;">
                        <select class="a-control" id="BrandID" name="BrandID" data-bind="options:_sorts,optionsText:'Title',optionsValue:'Id',optionsCaption:'--选择--',value:searchModel().BrandID">
                            <option value="0">--选择--</option>
                        </select>
                    </td>
                    <td style="width:100px;">
                        <select class="a-control" id="ProvinceID" name="ProvinceID" data-bind="options:_parts,optionsText:'Name',optionsValue:'ID',optionsCaption:'--选择--',value:searchModel().ProvinceID">
                            <option value="0">--省--</option>
                        </select>
                    </td>
                    <td>
                        <input type="text" class="a-control" placeholder="请输入要查询关键字" style="width: 200px;" data-bind="value:searchModel().keyword">
                    </td>
                    <td>
                        <button type="button" class="a-btn-search" data-bind="click:search"></button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div>
        <table class="table table-hover" data-bind="with:dataTable">
            <thead>
                <tr>
                    <th style="width:20px;"></th>
                    <th>商家名称</th>
                    <th>省份</th>
                    <th>地址</th>
                    <th>分类</th>

                    <th>电话</th>
                    <th>创建时间</th>
                    <th>经度纬度</th>

                </tr>
            </thead>
            <tbody data-bind="foreach:models">
                <tr data-bind="click:$parent.selectRow">
                    <td data-bind="text:ID"></td>
                    <td data-bind="text:ShopName"></td>
                    <td data-bind="text:$ace.findName(_parts,ProvinceID(),'ID','Name')"></td>
                    <td data-bind="text:ShopAddress"></td>
                    <td data-bind="text:$ace.findName(_sorts,BrandID(),'Id','Title')"></td>

                    <td data-bind="text:ShopTel"></td>
                    <td data-bind="dateString:CreateDate"></td>
                    <td><span data-bind="text:GPS_X"></span>,<span data-bind="text:GPS_Y"></span></td>



                </tr>
            </tbody>
            @Html.Partial("_tfoot")
        </table>
    </div>
</div>

<dialogbox data-bind="with:dialog" style="width:80%;">
    <form id="form1">

        <table class="form-table">
            <tbody>
                <tr>
                    <td class="form-title">商家名称</td>
                    <td class="form-value">
                        <input name="ShopName" id="ShopName" type="text" class="a-control required" placeholder="请输入商家名称" data-bind="value:model().ShopName" />
                    </td>
                    <td class="form-title">商家分类</td>
                    <td class="form-value">
                        <select name="BrandID" id="BrandID" type="text" class="a-control required" data-bind="options:_sorts,optionsText:'Title',optionsValue:'Id',optionsCaption:'--选择分类--',value:model().BrandID"></select>
                    </td>
                </tr>

                <tr>
                    <td class="form-title">商家地址</td>
                    <td class="form-value">
                        <input name="ShopAddress" id="ShopAddress" type="text" class="a-control required" placeholder="请输入商家地址" data-bind="value:model().ShopAddress" />
                    </td>
                    <td class="form-title">商家电话</td>
                    <td class="form-value">
                        <input name="ShopTel" id="ShopTel" type="text" class="a-control required" placeholder="请输入商家电话" data-bind="value:model().ShopTel" />
                    </td>
                </tr>

                <tr>
                    <td class="form-title">省</td>
                    <td class="form-value">
                        <select name="ProvinceID" id="ProvinceID" type="text" class="a-control required" data-bind="options:_parts,optionsText:'Name',optionsValue:'ID',optionsCaption:'--选择分类--',value:model().ProvinceID"></select>
                    </td>
                    <td class="form-title"></td>
                    <td class="form-value">
                        <input style="display:none;" name="GPS_X" id="GPS_X" type="text" class="a-control required" placeholder="请输入商家经度" data-bind="value:model().GPS_X" />
                        <input style="display:none;" name="GPS_Y" id="GPS_Y" type="text" class="a-control required" placeholder="请输入商家纬度" data-bind="value:model().GPS_Y" />
                    </td>
                </tr>
            </tbody>
        </table>
        <table class="form-table">
            <tbody>

                <tr>
                    <td class="form-title">商家简介</td>
                    <td class="form-value">
                        <input name="Summary" id="Summary" type="text" class="a-control required" placeholder="请输入简介" data-bind="value:model().Summary" />
                    </td>
                </tr>

                <tr>
                    <td class="form-title">图片</td>
                    <td class="form-value">
                        <div class="input-group">
                            <input name="ShopUrl" id="ShopUrl" type="text" class="a-control" data-bind="value:model().ShopUrl">
                            <span class="input-group-btn">
                                <button type="button" id="btn_banner" class="a-btn"><i class="fa fa-upload"></i></button>
                            </span>
                        </div>
                    </td>
                </tr>
                <tr style="display:none;">
                    <td class="form-title"></td>
                    <td class="form-value">
                        <div id="thelist" class="uploader-list"></div>
                    </td>
                </tr>
            </tbody>
        </table>

    </form>
</dialogbox>


<dialogbox data-bind="with:revisePasswordDialog" style="width:500px">
    <form id="RevisePasswordForm">
        <table class="form">
            <tr>
                
                <td class="form-value">
                    <img src="" id="shopcode"  />
                </td>
            </tr>
        </table>
    </form>
</dialogbox>

<script type="text/javascript">
    jQuery(function () {


        $("#btn_banner").dropzone({
            url: "/file/FileSave",
            previewsContainer: "#thelist",
            success: function (file, data) {
                var json = $.parseJSON(data);
                $("#ShopUrl").val(json.Url);
            }
        });

    });

</script>
